package ac.github.os.internal.core.action.entity

import ac.github.os.internal.core.action.IEntityAction
import ac.github.os.internal.core.config.StringConfig
import ac.github.os.internal.core.config.get
import ac.github.os.internal.session.Cache
import ac.github.os.internal.session.Session
import org.bukkit.Location
import taboolib.common.platform.Awake

@Awake
class TeleportAction : IEntityAction {
    override fun onExecute(session: Session, cache: Cache, config: StringConfig) {
        val location = config.get<Location>("loc", single = true) ?: return
        cache.filterIsEntities().forEach {
            it.teleport(location)
        }
    }

    override val namespace: String
        get() = "entity:tp"
}
